#include<iostream>
#include<vector>
#include<math.h>

using namespace std;

int main(){
	int n,r,minx=50,miny=50,maxx=0,maxy=0,maxr=0,resx,resy;
	cin>>n>>r;
	vector<vector<int>> towers(n,vector<int>(3,0));
	for(int i=0;i<n;i++){
		cin>>towers[i][0]>>towers[i][1]>>towers[i][2];
		minx = min(minx, towers[i][0]);
		maxx = max(maxx, towers[i][0]);
		miny = min(miny, towers[i][1]);
		maxy = max(maxy, towers[i][1]);
	}
	
	for(int i=minx;i<=maxx;i++){
		for(int j=miny;j<=maxy;j++){
			int ra = 0;
			for(int k=0;k<n;k++){
				int dis = sqrt((towers[k][0] - i)*(towers[k][0] - i) + (towers[k][1] - j)*(towers[k][1] - j));
				if(dis<=r){
					ra += towers[k][2] / (1+dis);
				}
			}
			if(ra>maxr){
				maxr = ra;
				resx = i;
				resy = j;
			}
		}
	}
	
	cout<<resx<<' '<<resy;
	return 0;
}
